﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
using Zj.DDDSample.Domain.Core;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Zj.DDDSample.Repositories.EntityFrameworkCore.Models.Mappings
{
    /// <summary>
    /// Project fluent api mapping.
    /// </summary>
    public class ProjectMap
        : IEntityTypeConfiguration<Project>
    {
        public void Configure(EntityTypeBuilder<Project> builder)
        {
            //table
            builder.ToTable("Project", "dbo");

            //keys
            builder.HasKey(t => t.Id);

            //properties
            builder.Property(t => t.Id)
                .HasColumnName("Id")
                .IsRequired();

            builder.Property(t => t.CreateTime)
                .HasColumnName("CreateTime")
                .IsRequired();

            builder.Property(t => t.Name)
                .HasColumnName("Name")
                .HasMaxLength(20)
                .IsRequired();

            builder.Property(t => t.StartTime)
                .HasColumnName("StartTime")
                .IsRequired();

            builder.Property(t => t.EndTime)
                .HasColumnName("EndTime")
                .IsRequired();
        }
    }
}
